// 美团搜索框
// 获取变量
const search = document.querySelector('.search')
const searchPrompt = document.querySelector('.searchPrompt')
// 事件触发
search.oninput = function () {
    const word = this.value.trim()
    const script = document.createElement('script')
    script.src = 'https://www.baidu.com/sugrec?pre=1&p=3&ie=utf-8&json=1&prod=pc&from=pc_web&sugsid=34649,34446,34067,31660,34552,34004,34525,34584,34106,26350,34627,34416&wd='+ word +'&req=2&csor=1&cb=fn&_=1632360398126'
    document.body.appendChild(script)
    script.remove()
}
// 渲染ul li
function fn(res) {
    if (!res.g) return searchPrompt.style.display = 'none'
    let str = ''
    res.g.forEach(item => {
        str += `<li>${ item.q }</li>`
    })
    searchPrompt.innerHTML = str
    searchPrompt.style.display = 'block'
}
